<?php
require_once(dirname(__FILE__)."/../include/common.inc.php");	
$row = $dsql->GetOne("SELECT * FROM `#@__weixin` WHERE id=1");
$ACCESS_TOKEN = $row['ACCESS_TOKEN'];
//$menu = $row['menu'];
$menu = $_GET['menu'];
header("Content-type: text/html; charset=utf-8");
define("ACCESS_TOKEN", $ACCESS_TOKEN);

//创建菜单
function createMenu($data){
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://api.weixin.qq.com/cgi-bin/menu/create?access_token=".ACCESS_TOKEN);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (compatible; MSIE 5.01; Windows NT 5.0)');
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_AUTOREFERER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$tmpInfo = curl_exec($ch);
if (curl_errno($ch)) {
return curl_error($ch);
}
curl_close($ch);
return $tmpInfo;
}

$data =$menu;
echo createMenu($data);//创建菜单
?>